import { asyncRouter, constantRoutes } from '@/router'
const state = {
  routes: []
}
const mutations = {
  setRouter(state, data) {
    state.routes = [
      ...constantRoutes,
      ...data
    ]
  }
}
const actions = {

  filterRouter(store, menus) {
    const routes = asyncRouter.filter(route => {
      return menus.includes(route.name)
    })
    store.commit('setRouter', routes)
    return routes
  }

}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
